package LuoGu.模拟与高精度.回文质数;

import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int l = s.nextInt();
        int r = s.nextInt();
        int [] temp = new int [r+1];
        Arrays.fill(temp,1);
        for(int i=2;i<=r;i++){
            if(temp[i]==1){
                for(int j=i*2;j<=r;j+=i){
                    temp[j] = 0;
                }
            }
        }
        for(int i=l;i<r+1;i++){
            if(temp[i]==1){
                StringBuffer temp1 = new StringBuffer(String.valueOf(i));
                if(temp1.reverse().toString().equals(String.valueOf(i))) System.out.println(i);
            }
        }
    }
}
